import CommonAction from "../../../../../actions/common";

export default class HeaderAction extends CommonAction {
    constructor(comp) {
        super();
        this.comp = comp;
        this.dispatchType = 'staffCom/getDimiInfo'; //查询数据用到
    }

    getPostData = () => {
        let {advObj, searchVal, pageInfo} = this.comp.state;
        let pk_org = advObj.org && advObj.org.map(item => {
            return item.refpk
        }) 
        let pk_psncl = advObj.psncl && advObj.psncl.map(item => {
            return item.refpk
        })

        return {
            begindate: advObj.rangeDate[0] || null,//	开始日期	string	yyyy-mm-dd
            enddate: advObj.rangeDate[1] || null,//	结束日期	string	yyyy-mm-dd
            pageIndex: pageInfo.pageIndex,//	页码	number
            pageSize: pageInfo.pageSize,//	一页条数	number
            pk_org: pk_org || null,//	组织	string	如果是从统计值穿透过来的,为统计值对应的pk_org,即部门主键
            pk_psncl: pk_psncl || null,//	人员类别	string
            qryStr: searchVal,//	模糊查询串	string
            pk_trnstype: advObj.pk_trnstype && advObj.pk_trnstype.refpk || null,//	离职类型 string
        }
    };

    clear = () => {
        let advObj = {
            org: null, //组织
            psncl: null, //人员类别
            jobRank: null, //职等
            staffCode: "", //员工编码
            contract: null, //合同主体
            age: null, //年龄
            edu: null, //学历
            rangeDate: [], //起止日期
        };
        this.updateState({advObj})
    };

    updateState = (obj) => {
        return new Promise(resolve => {
            this.comp.setState(obj, resolve);
        })
    }
}